﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MessageModule
{
    public partial class FormAutoHideMessage : DevExpress.XtraEditors.XtraForm
    {
        double dTimeDelay = 0;
        GeneralLib.HiPerfTimer  perfTimer = new GeneralLib.HiPerfTimer();
        public FormAutoHideMessage()
        {
            InitializeComponent();
        }
        public FormAutoHideMessage(string strMessage,double dDelayTime=3)
        {
            InitializeComponent();
            labelControlMessage.Text = strMessage;
            //timer1.Interval = (int)dDelayTime * 1000;
            labelControl1.Text = "窗体将关闭" + dDelayTime.ToString() +"Seconds";
            dTimeDelay= dDelayTime;
            perfTimer.Start();
        }

        private void FormAutoHideMessage_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            
            labelControl2.Text ="TimeRemaid:"+ (dTimeDelay - perfTimer.Duration).ToString("0.0");
            if(perfTimer.TimeUp(dTimeDelay))
                this.Close();
        }

        private void FormAutoHideMessage_FormClosed(object sender, FormClosedEventArgs e)
        {
            FrameManager.FrameManager.flyoutPanelStack.Controls.Remove(this);
            if (FrameManager.FrameManager.flyoutPanelStack.Controls.Count == 0)
            {
                FrameManager.FrameManager.flyoutPanel.HidePopup();
            }

        }
    }
}
